﻿Ext.define('Examples.crud.user.model.Model', {
    requires: ['Happy.data.proxy.Ajax'],
    extend: 'Ext.data.Model',

    idProperty: 'Id',
    fields: ['Id', 'Name', 'Email'],
    proxy: {
        type: 'happy-ajax',
        actionMethods: {
            create: 'GET',
            read: 'GET',
            update: 'GET',
            destroy: 'GET'
        },
        api: {
            create: 'app/user/server/create.txt',
            read: 'app/user/server/read.txt',
            load: 'app/user/server/load.txt',
            update: 'app/user/server/update.txt',
            destroy: 'app/user/server/destroy.txt'
        },
        reader: {
            type: 'json',
            root: 'items',
            idProperty: 'Id',
            messageProperty: 'message'
        },
        writer: {
            type: 'json',
            encode: true,
            root: 'item'
        }
    }
});